home *** CD-ROM | disk | FTP | other *** search
- /*
- * html-win32.c -- Win32 Console program rtftohtml wrapper
- *
- * Driver provides OpenOutputFile() and Basename() functions for the writer.
- */
- #include <windows.h>
- #include <stdio.h>
-
-
- # include "rtf.h"
- //# include "rtf-unix.h"
- # include "rtftohtml.h"
-
- extern HWND ghWndMain;
- static char *usage="rtftohtml [-V] [-i] [-G] [-T] [-o filename] [-P extension] file";
- static char *progPath = (char *) NULL;
-
- void Win32SetProgPath (path)
- char *path;
- {
- int i, j, n;
-
- n = strlen (path);
- for (j = -1, i = 0; i < n; i++)
- {
- if (path[i] == '/')
- j = i;
- }
- if (j < 0) /* no slash found */
- {
- path = ".";
- j = 1;
- }
- if ((progPath = RTFAlloc (j + 1)) != (char *) NULL)
- {
- (void) strncpy (progPath, path, j);
- progPath[j] = '\0';
- }
- }
-
- #define LIBDIR "."
-
- FILE *
- Win32OpenLibFile (file, mode)
- char *file;
- char *mode;
- {
- FILE *f;
- char buf[rtfBufSiz];
- char *p;
-
- if ((f = fopen (file, mode)) != (FILE *) NULL)
- {
- return (f);
- }
- /* if abolute pathname, give up, else look in library */
- if (file[0] == '/')
- {
- return ((FILE *) NULL);
- }
- if ((p = getenv ("RTFLIBDIR")) != (char *) NULL)
- {
- sprintf (buf, "%s/%s", p, file);
- if ((f = fopen (buf, mode)) != (FILE *) NULL)
- return (f);
- }
- if (progPath != (char *) NULL)
- {
- sprintf (buf, "%s/%s", progPath, file);
- if ((f = fopen (buf, mode)) != (FILE *) NULL)
- return (f);
- }
- sprintf (buf, "%s/%s", LIBDIR, file);
- f = fopen (buf, mode); /* NULL if it fails */
- return (f);
- }
-
-
- int mainconv(int argc,char *argv[])
- {
- /* install OS-specific callbacks into RTF library */
- Win32SetProgPath (argv[0]);
- RTFSetOpenLibFileProc (Win32OpenLibFile);
-
- WriterInit ();
- RTFInit ();
- switch (do_main(argc,argv)) /* set up for output file */
- {
- case 1: /* successful */
- RTFRead ();
- HTMLCleanup();
- break;
- case 0: /* unsuccessful; die */
- RTFPanic ("Error in input file. Check that input file is RTF format");
- case -1: /* unsuccessful; print usage message and die*/
- RTFPanic ("Usage: %s", usage);
- }
- return 0;
- }
-
-
- FILE *
- OpenOutputFile (name, mode, fileType)
- char *name;
- char *mode;
- int fileType; /* ignored */
- {
- return (fopen (name, mode));
- }
-
-
- # define pathSep '/'
-
- char * Basename (char *name)
- {
- int i, lsep;
- for(i=0,lsep=0;name[i]!='\0';i++) {
- if(name[i]==pathSep)
- lsep=i+1;
- }
- return (&name[lsep]);
- }
-